﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title></title>
    <!-- Bootstrap Styles-->
    <link href="assets/css/bootstrap.css" rel="stylesheet" />
    <!-- FontAwesome Styles-->
    <link href="assets/css/font-awesome.css" rel="stylesheet" />
    <!-- Morris Chart Styles-->

    <!-- Custom Styles-->
    <link href="assets/css/custom-styles.css" rel="stylesheet" />
    <!-- Google Fonts-->
    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
    <!-- TABLE STYLES-->
    <link href="assets/js/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
    <style>
        .form-group{
            margin-bottom: 10px;
        }
    </style>
</head>

<body class="sub-body">
<!-- /. NAV SIDE  -->
<div id="sub-page-wrapper">
    <div id="sub-page-inner">
        <div class="col-md-12">
            <!--    Context Classes  -->
            <div class="panel panel-default">

                <div class="panel-heading">
                    <button class="btn btn-primary" @click="open_model(-1)">添加任务</button>
                </div>

                <div class="panel-body">
                    <div class="table-responsive">
                        <table class="table">
                            <thead>
                            <tr>
                                <th>#ID</th>
                                <th>任务名称</th>
                                <th>cron表达式</th>
                                <th>上次执行</th>
                                <th>下次执行</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr v-for="(item,index) in taskLists" :key="index">
                                <td>{{ item.Id }}</td>
                                <td>{{ item.TaskName }}</td>
                                <td>{{ item.CronSpec }}</td>
                                <td>{{ item.PrevTime }}</td>
                                <td>{{ item.NextTime }}</td>
                                <td width="300">
                                    <a href="javascript:void(0);" @click="update_task_status(item.Id,'1')" v-if="item.Status == 0" class="btn btn-danger btn-sm">启动</a>
                                    <a href="javascript:void(0);" @click="update_task_status(item.Id,'0')" v-if="item.Status == 1" class="btn btn-success btn-sm">暂停</a>
                                    <a href="javascript:void(0);" @click="run_task(item.Id);" class="btn btn-primary btn-sm">执行</a>
                                    <a href="javascript:void(0);" @click="open_model(index)" class="btn btn-info btn-sm">编辑</a>
                                    <a href="javascript:void(0);" @click="del_task(item.Id)" class="btn btn-danger btn-sm" >删除</a>
                                    <a target="content-frm" :href="'cron-log.html?task_id=' + item.Id" class="btn btn-default btn-sm" >日志</a>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>

                <div class="panel-body">
                    <div id="Paginator" style="text-align: center"> <ul id="pageLimit"></ul> </div>
                </div>
            </div>
            <!--  end  Context Classes  -->
        </div>

        <!-- 添加任务对话框 -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
             aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="myModalLabel">添加任务</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <input class="form-control" id="task-name" v-model="task.TaskName" placeholder="任务名称">
                        </div>
                        <div class="form-group">
                            <textarea class="form-control" v-model="task.Description" rows="3" placeholder="任务说明"></textarea>
                        </div>
                        <div class="form-group">
                            <select class="form-control" v-model="task.GroupId">
                                <option value="0">未分组</option>
                                <option v-for="(e,i) in taskGroupLists" :key="i" :value="e.Id">{{e.GroupName}}</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <input class="form-control" v-model="task.Concurrent" placeholder="并发协程数，默认：1">
                        </div>
                        <div class="form-group">
                            <input class="form-control" v-model="task.CronSpec" placeholder="cron 表达式">
                        </div>
                        <div class="form-group">
                            <textarea class="form-control" v-model="task.Command" rows="3" placeholder="脚本命令"></textarea>
                        </div>
                        <div class="form-group">
                            <input class="form-control" v-model="task.Timeout" placeholder="超时设置,默认: 86400">
                        </div>
                        <div class="form-group">
                            <label>邮件通知</label>
                            <label class="radio-inline">
                                <input type="radio" v-model="task.Notify" value="0" checked=""> 不通知
                            </label>
                            <label class="radio-inline">
                                <input type="radio" v-model="task.Notify" value="1" >失败通知
                            </label>
                            <label class="radio-inline">
                                <input type="radio" v-model="task.Notify" value="2">结束通知
                            </label>
                        </div>
                        <div class="form-group" v-show="task.Notify != 0">
                            <textarea class="form-control" v-model="task.NotifyEmail" rows="3" placeholder="邮件通知抄送人,每行一个email地址，如果不需要抄送给其他人请留空"></textarea>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" @click="save_task();" class="btn btn-primary">保存</button>
                    </div>
                </div>
            </div>
        </div>
        <!-- End Modals-->
    </div>
</div>
<!-- /. PAGE INNER  -->
<!-- /. PAGE WRAPPER  -->
<!-- JS Scripts-->
<!-- jQuery Js -->
<script src="assets/js/jquery-1.10.2.js"></script>
<!-- Bootstrap Js -->
<script src="assets/js/bootstrap.min.js"></script>
<!-- Metis Menu Js -->
<script src="assets/js/jquery.metisMenu.js"></script>
<!-- DATA TABLE SCRIPTS -->
<script src="assets/js/dataTables/jquery.dataTables.js"></script>
<script src="assets/js/dataTables/dataTables.bootstrap.js"></script>

<script src="assets/js/bootstrap-paginator.js"></script>

<script src="assets/js/axios.min.js"></script>
<script src="assets/js/global.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="assets/js/cron-tasks.js"></script>

</body>
</html>